package com.softstao.guoyu.mvp.interactor.me;

import com.softstao.guoyu.global.APIInterface;
import com.softstao.guoyu.model.me.AgentInfo;
import com.softstao.guoyu.model.me.ApplyListIndex;
import com.softstao.guoyu.model.me.Balance;
import com.softstao.guoyu.model.me.BalanceIndex;
import com.softstao.guoyu.model.me.RechargeApply;
import com.softstao.guoyu.model.me.RechargeCondition;
import com.softstao.guoyu.mvp.interactor.BaseInteractor;
import com.softstao.guoyu.utils.MyHttpParams;

import rx.functions.Action1;

/**
 * Created by vaikus on 2017/6/15.
 */

public class BalanceInteractor extends BaseInteractor {
    public void getRechargeList(int page, int agentId, int inorout,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"inorout",inorout,"pageSize","12","pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.AGENT_RECHARGE_LIST)
                .setType(Balance.class)
                .getVolley()
                .post(params);
    }

    public void getBalance(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.GET_BALANCE)
                .setType(BalanceIndex.class)
                .getVolley()
                .post(params);
    }

    public void getApplyList(int page, int agentId, String search,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"pageSize","12","pageIndex",page, "search", search);
        builder.setAction(action1)
                .setUrl(APIInterface.CHILDREN_RECHARGE_LIST)
                .setType(ApplyListIndex.class)
                .getVolley()
                .post(params);
    }

    public void getAgentInfo(int agentId,int subAgentId,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"subAgentId",subAgentId);
        builder.setAction(action1)
                .setUrl(APIInterface.CHILDREN_RECHARGE_DETAIL)
                .setType(AgentInfo.class)
                .getVolley()
                .post(params);
    }

    public void addRecharge(RechargeCondition condition,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        builder.setAction(action1)
                .setUrl(APIInterface.ADD_RECHARGE)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void getRechargeApply(int page,int agentId,String state,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"state",state,"pageSize","8","pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.RECHARGE_APPLY_LIST)
                .setType(RechargeApply.class)
                .getVolley()
                .post(params);
    }

    public void urge(int agentId,int applyId,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"applyId",applyId);
        builder.setAction(action1)
                .setUrl(APIInterface.URGE_RECHARGE)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void cancel(int agentId,int applyId,String reason,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"applyId",applyId,"reason",reason);
        builder.setAction(action1)
                .setUrl(APIInterface.CANCEL_RECHARGE)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void apply(RechargeCondition condition,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        builder.setAction(action1)
                .setUrl(APIInterface.ADD_RECHARGE_APPLY)
                .setType(null)
                .getVolley()
                .post(params);
    }
}
